package com.example.cdctest.controller;

import com.example.cdctest.pojo.TestPaper;
import com.example.cdctest.pojo.UserInfo;
import com.example.cdctest.service.TestPaperService;
import com.example.cdctest.service.UserInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/services")
public class TestPaperController {
    @Resource
    private TestPaperService testPaperService;
    @Resource
    private UserInfoService userInfoService;

    @RequestMapping("examination_record")
    public ModelAndView examination_record(HttpSession session) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("services/examination_record");
        UserInfo userInfo = (UserInfo) session.getAttribute("loginUser");
        String email=userInfo.getEmail();
        modelAndView.addObject("testPaper",testPaperService.selectAllByEmail(email));
        modelAndView.addObject("userInfo",userInfoService.selectUserByEmail(email));
        return modelAndView;
    }
}
